package app.sys.error;

import app.sys.data.comm.ApiCode;
import app.sys.data.comm.ApiResult;
import lombok.Data;

@Data
public class BizException extends RuntimeException {
    private final String status;

    /**
     * 通过状态码和异常信息创建异常对象
     *
     * @param status
     * @param message
     */
    public BizException(String status, String message) {
        super(message);
        this.status = status;
    }

    /**
     * 接受枚举类型对象
     *
     * @param apiResult
     */
    public BizException(ApiResult apiResult) {
        super(apiResult.getMsg());
        this.status = apiResult.getStatus();
    }

    /**
     * 接受枚举类型对象
     *
     * @param apiCode
     */
    public BizException(ApiCode apiCode) {
        super(apiCode.getMsg());
        this.status = apiCode.getStatus();
    }

    /**
     * 字符串
     *
     * @param msg
     */
    public BizException(String msg) {
        super(msg);
        this.status = ApiCode.FAIL.getStatus();
    }


}
